//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CLog {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CLog(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CLog obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CLog(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CLog(CLog.TLogType logType) {
    this(nelmiscJNI.new_CLog__SWIG_0(logType.swigValue()), true);
  }

  public CLog() {
    this(nelmiscJNI.new_CLog__SWIG_1(), true);
  }

  public void addDisplayer(IDisplayer displayer, boolean bypassFilter) {
    nelmiscJNI.CLog_addDisplayer__SWIG_0(swigCPtr, this, IDisplayer.getCPtr(displayer), displayer, bypassFilter);
  }

  public void addDisplayer(IDisplayer displayer) {
    nelmiscJNI.CLog_addDisplayer__SWIG_1(swigCPtr, this, IDisplayer.getCPtr(displayer), displayer);
  }

  public IDisplayer getDisplayer(String displayerName) {
    long cPtr = nelmiscJNI.CLog_getDisplayer(swigCPtr, this, displayerName);
    return (cPtr == 0) ? null : new IDisplayer(cPtr, false);
  }

  public void removeDisplayer(IDisplayer displayer) {
    nelmiscJNI.CLog_removeDisplayer__SWIG_0(swigCPtr, this, IDisplayer.getCPtr(displayer), displayer);
  }

  public void removeDisplayer(String displayerName) {
    nelmiscJNI.CLog_removeDisplayer__SWIG_1(swigCPtr, this, displayerName);
  }

  public boolean attached(IDisplayer displayer) {
    return nelmiscJNI.CLog_attached(swigCPtr, this, IDisplayer.getCPtr(displayer), displayer);
  }

  public boolean noDisplayer() {
    return nelmiscJNI.CLog_noDisplayer(swigCPtr, this);
  }

  public static void setProcessName(String processName) {
    nelmiscJNI.CLog_setProcessName(processName);
  }

  public static void setDefaultProcessName() {
    nelmiscJNI.CLog_setDefaultProcessName();
  }

  public void setPosition(int line, String fileName, String funcName) {
    nelmiscJNI.CLog_setPosition__SWIG_0(swigCPtr, this, line, fileName, funcName);
  }

  public void setPosition(int line, String fileName) {
    nelmiscJNI.CLog_setPosition__SWIG_1(swigCPtr, this, line, fileName);
  }

  public void displayNL(String format) {
    nelmiscJNI.CLog_displayNL(swigCPtr, this, format);
  }

  public void display(String format) {
    nelmiscJNI.CLog_display(swigCPtr, this, format);
  }

  public void displayRawNL(String format) {
    nelmiscJNI.CLog_displayRawNL(swigCPtr, this, format);
  }

  public void displayRaw(String format) {
    nelmiscJNI.CLog_displayRaw(swigCPtr, this, format);
  }

  public void forceDisplayRaw(String format) {
    nelmiscJNI.CLog_forceDisplayRaw(swigCPtr, this, format);
  }

  public void addPositiveFilter(String filterstr) {
    nelmiscJNI.CLog_addPositiveFilter(swigCPtr, this, filterstr);
  }

  public void addNegativeFilter(String filterstr) {
    nelmiscJNI.CLog_addNegativeFilter(swigCPtr, this, filterstr);
  }

  public void resetFilters() {
    nelmiscJNI.CLog_resetFilters(swigCPtr, this);
  }

  public void removeFilter(String filterstr) {
    nelmiscJNI.CLog_removeFilter__SWIG_0(swigCPtr, this, filterstr);
  }

  public void removeFilter() {
    nelmiscJNI.CLog_removeFilter__SWIG_1(swigCPtr, this);
  }

  public void displayFilter(CLog log) {
    nelmiscJNI.CLog_displayFilter(swigCPtr, this, CLog.getCPtr(log), log);
  }

  public static void releaseProcessName() {
    nelmiscJNI.CLog_releaseProcessName();
  }

  public final static class TLogType {
    public final static TLogType LOG_NO = new TLogType("LOG_NO", nelmiscJNI.CLog_LOG_NO_get());
    public final static TLogType LOG_ERROR = new TLogType("LOG_ERROR");
    public final static TLogType LOG_WARNING = new TLogType("LOG_WARNING");
    public final static TLogType LOG_INFO = new TLogType("LOG_INFO");
    public final static TLogType LOG_DEBUG = new TLogType("LOG_DEBUG");
    public final static TLogType LOG_STAT = new TLogType("LOG_STAT");
    public final static TLogType LOG_ASSERT = new TLogType("LOG_ASSERT");
    public final static TLogType LOG_UNKNOWN = new TLogType("LOG_UNKNOWN");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TLogType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TLogType.class + " with value " + swigValue);
    }

    private TLogType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TLogType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TLogType(String swigName, TLogType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TLogType[] swigValues = { LOG_NO, LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG, LOG_STAT, LOG_ASSERT, LOG_UNKNOWN };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
